<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     * 用户表
     */
    public function up()
    {
        Schema::create('system_users', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->string('username', 200)->default('')->comment('浙政钉账号');
            $table->string('phone', 11)->default('')->comment('手机号');
            $table->string('name', 60)->default('')->comment('名字');
            $table->string('password', 255)->default('')->comment('密码');
            $table->string('remember_token', 500)->default('')->comment('登陆token');
            $table->string('last_login_ip', 20)->default('')->comment('登陆IP');
            $table->timestamp('last_login_time')->nullable()->comment('最后登陆时间');
            $table->tinyInteger('is_deleted')->default(0)->comment('0正常，1删除');
            $table->integer('department_id')->default(1)->comment('部门id');
            $table->tinyInteger('status')->default(1)->comment('1启用2禁用');
            $table->tinyInteger('is_author')->default(1)->comment('1否2作者3两者都是');
            $table->integer('department_one_id')->default(0)->comment('部门1id');
            $table->integer('department_two_id')->default(0)->comment('部门1id');
            $table->integer('department_three_id')->default(0)->comment('部门1id');
            $table->integer('type')->default(1)->comment('1总部员工，2分部员工');
            $table->longText('data_permission')->default('')->comment('数据权限');
            $table->timestamps();
        });
        \DB::statement("ALTER TABLE `system_users` comment '后台管理员表'");
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('system_users');
    }
};
